package com.mofeng.myshop.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mofeng.myshop.domain.po.Address;
import com.mofeng.myshop.domain.po.AddressMap;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 发货地址 Mapper 接口
 * </p>
 *
 * @author MoFeng
 * @since 2024-04-17
 */
public interface AddressMapMapper extends BaseMapper<AddressMap> {

    @Select({"<script>",
            "SELECT * FROM `tb_address`",
            "WHERE 1 = 1 ",
            "<if test='projectId != null'>",
            "AND `project_id` = #{projectId}",
            "</if>",
            "<if test='port != null'>",
            "AND `port` = #{port}",
            "</if>",
            "<if test='mapType != null'>",
            "AND `map_type` = #{mapType}",
            "</if>",
            " ORDER BY `order_index` , `update_time` DESC",
            "</script>"})
    Page<AddressMap> findByList(@Param("projectId") Long projectId,
                                @Param("mapType") String mapType,
                                @Param("port") Integer port,
                                Page<AddressMap> pageMp);

    @Select("SELECT * FROM `tb_address` ")
    List<AddressMap> findAll();
}
